module.exports = (sequelize, DataTypes) => {
    const orderModel = sequelize.import('./order.model')
    const car = sequelize.define('car', {
        car_id: {
            type: DataTypes.INTEGER,
            primaryKey: true,
            autoIncrement: true,
            defaultValue:0
        },
        car_status: {
            type: DataTypes.ENUM('空闲','运输中','已到达'),
            allowNull: false
        },
        dest_place: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        origin_place: {
            type: DataTypes.STRING,
            allowNull: false
        },
        duration: {
            type: DataTypes.INTEGER,
            allowNull: false
        }
    },{
        timestamps:false,
        tableName:'trans_info'
    })
    car.hasMany(orderModel,{
        foreignKey: 'car_id',
        sourceKey: 'car_id',
        onUpdate: 'SET NULL',
        onDelete: 'SET NULL'
    })
    return car
}
